//
//  DB.m
//  Double
//
//  Created by dllo on 15/5/26.
//  Copyright (c) 2015年 袁庆秋. All rights reserved.
//

#import "DB.h"
static sqlite3 * dbPoint = nil;
@implementation DB

+ (sqlite3 *)openDB
{
    if (dbPoint) {
        return dbPoint;
    }
    NSFileManager * manager = [NSFileManager defaultManager];
    NSArray * array = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString * path = [array lastObject];
    path = [NSString stringWithFormat:@"%@/我的.rdb",path];
    NSLog(@"path = %@", path);
    if (![manager fileExistsAtPath:path]) {
        NSString * atPath = [[NSBundle mainBundle]pathForResource:@"Animation.rdb" ofType:nil];
        [manager copyItemAtPath:atPath toPath:path error:nil];
    }
    sqlite3_open([path UTF8String], &dbPoint);
    return dbPoint;
}
+ (void)closeDB
{
    sqlite3_close(dbPoint);
}

@end
